/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.liquidByte.trafficMustang.server.dataModel;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.List;
import javax.persistence.*;
import javax.validation.constraints.NotNull;

/**
 *
 * @author Alexandre
 */
@Entity
@Table(name = "motr")
public class Motorista implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @NotNull
    @Column(name = "USR_ID")
    private Integer usrId;
    @Basic(optional = false)
    @NotNull
    @Column(name = "MOTR_VL_PADR")
    private BigDecimal motrVlPadr;
    @OneToMany(mappedBy = "motrId")
    private List<Deslocamento> deslocamentoList;
    @JoinColumn(name = "USR_ID", referencedColumnName = "USR_ID", insertable = false, updatable = false)
    @OneToOne(optional = false)
    private Usuario usuario;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "motrId", orphanRemoval=true)
    private List<Veiculo> veiculoList;

    public Motorista() {
    }

    public Motorista(Integer usrId) {
        this.usrId = usrId;
    }

    public Motorista(Integer usrId, BigDecimal motrVlPadr) {
        this.usrId = usrId;
        this.motrVlPadr = motrVlPadr;
    }

    public Integer getUsrId() {
        return usrId;
    }

    public void setUsrId(Integer usrId) {
        this.usrId = usrId;
    }

    public BigDecimal getMotrVlPadr() {
        return motrVlPadr;
    }

    public void setMotrVlPadr(BigDecimal motrVlPadr) {
        this.motrVlPadr = motrVlPadr;
    }

    public List<Deslocamento> getDeslocamentoList() {
        return deslocamentoList;
    }

    public void setDeslocamentoList(List<Deslocamento> deslocamentoList) {
        this.deslocamentoList = deslocamentoList;
    }

    public Usuario getUsuario() {
        return usuario;
    }

    public void setUsuario(Usuario usuario) {
        this.usuario = usuario;
    }

    public List<Veiculo> getVeiculoList() {
        return veiculoList;
    }

    public void setVeiculoList(List<Veiculo> veiculoList) {
        this.veiculoList = veiculoList;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (usrId != null ? usrId.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Motorista)) {
            return false;
        }
        Motorista other = (Motorista) object;
        if ((this.usrId == null && other.usrId != null) || (this.usrId != null && !this.usrId.equals(other.usrId))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "org.liquidByte.trafficMustang.server.dataModel.Motorista[ usrId=" + usrId + " ]";
    }
    
}
